package models

import (
	"go-web/utils"
)

type AdminUser struct {
	utils.BaseModel
	Username string `json:"username" gorm:"size:50;uniqueIndex;comment:用户名"`
	Nickname string `json:"nickname" gorm:"size:50;comment:昵称"`
	Password string `json:"password" gorm:"size:32;comment:密码"`
	Auth     string `json:"auth" gorm:"size:255;default:;comment:权限，多个菜单权限用逗号分割(all：所有权限，空字符表示无任何权限)"`
}

func GetUserByUsername(username string) AdminUser {
	db := utils.GetDB()
	var user AdminUser
	db.Where("username = ?", username).Find(&user)
	return user
}

func GetUserByUid(uid uint) AdminUser {
	db := utils.GetDB()
	var user AdminUser
	db.Where("id = ?", uid).Find(&user)
	return user
}
